package com.ruoyi.truth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.truth.domain.QualInfo;
import com.ruoyi.truth.service.IQualInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上传企业信息Controller
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/truth/qualinfo")
public class QualInfoController extends BaseController
{
    @Autowired
    private IQualInfoService qualInfoService;
    //private HttpKit httpKit;

    /**
     * 查询上传企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualInfo qualInfo)
    {
        startPage();
        List<QualInfo> list = qualInfoService.selectQualInfoList(qualInfo);
        return getDataTable(list);
    }

    /**
     * 导出上传企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:export')")
    @Log(title = "上传企业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualInfo qualInfo)
    {
        List<QualInfo> list = qualInfoService.selectQualInfoList(qualInfo);
        ExcelUtil<QualInfo> util = new ExcelUtil<QualInfo>(QualInfo.class);
        util.exportExcel(response, list, "上传企业信息数据");


    }

    /**
     * 获取上传企业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:query')")
    @GetMapping(value = "/{qualId}")
    public AjaxResult getInfo(@PathVariable("qualId") Long qualId)
    {

        return success(qualInfoService.selectQualInfoByQualId(qualId));
    }

    /**
     * 新增上传企业信息
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:add')")
    @Log(title = "上传企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualInfo qualInfo)
    {
        return toAjax(qualInfoService.insertQualInfo(qualInfo));
    }
    /**
     * 修改上传企业信息
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:edit')")
    @Log(title = "上传企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualInfo qualInfo)
    {
        return toAjax(qualInfoService.updateQualInfo(qualInfo));
    }

    /**
     * 删除上传企业信息
     */
    @PreAuthorize("@ss.hasPermi('truth:qualinfo:remove')")
    @Log(title = "上传企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{qualIds}")
    public AjaxResult remove(@PathVariable Long[] qualIds)
    {
        return toAjax(qualInfoService.deleteQualInfoByQualIds(qualIds));
    }

    private class string {
    }
}
